<html>
<head>
    <style>
        .error {
            color: #ff0000;
        }
    </style>
    <script src="../web/js/jquery/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="../web/js/jquery/jquery.numberformatter-1.2.js" type="text/javascript"></script>
    <script src="../web/js/misc/misc.js" type="text/javascript"></script>
    <script>


        $(document).ready(function() {
            alert('start');

            //   $("input").each(function(i, data){
            //      //$(this).format({format:"#,###.00", locale:"en"});
            //       var rawValue = jQuery(data).val();
            //       var v = jQuery(data).parseNumber({format:fmt});
            //       var txt = jQuery(data).formatNumber({format:fmt}, true);
            //       alert("raw:{0}\nfmt:{1}\nparse:{2}\nformat:{3}".fmt(rawValue, fmt, v, txt));
            ////       var fo = {format:fmt, locale:"en"};
            ////       alert(fo);
            ////       var val = $(v).format(fo);
            ////       alert(i+'='+val);
            //   });

            $("input").each(function(i, data) {
                var fmt = $(this).attr('fmt');
                $(this).parseNumber({format:fmt, locale:"us"});
                $(this).formatNumber({format:fmt, locale:"us"});

                $(this).keyup(function(e){
                });
            });


            $("input").blur(function() {
                var fmt = $(this).attr('fmt');
                $(this).formatNumber({format:fmt, locale:"us"});
            });

            $("input").focus(function() {
                var fmt = $(this).attr('fmt');
                $(this).parseNumber({format:fmt, locale:"us"});
                $(this).select();
            });

            //
            //   alert("Should be 2342.34 " + $("#parseTest1").parse({locale:"en"}));
            //   alert("Should be 2342.34 " + $("#parseTest2").parse({locale:"en"}));
            //   alert("Should be -2342.34 " + $("#parseTest3").parse({locale:"en"}));
            //   alert("Should be -2342.34 " + $("#parseTest4").parse({locale:"en"}));
            //   alert("Should be -2342.34 " + $("#parseTest5").parse({locale:"en"}));
            //   alert("Should be 2342.34 " + $("#parseTest6").parse({locale:"en"}));
            //   alert("Should be 2342 " + $("#parseTest7").parse({locale:"en"}));
            //   alert("Should be 0.2342 " + $("#parseTest8").parse({locale:"en"}));
            //
            //
            //   $(".check").each(function(){
            //      if ($(this).text() != $(this).next().text())
            //         $(this).next().addClass("error");
            //   });


            //   alert("This should all be the same decimal - " + $("#formatTest1").parse({locale:"en"}) + " " + $("#formatTestDe1").parse({locale:"de"}) + " " + $("#formatTestFr1").parse({locale:"fr"}) + " " + $("#formatTestCh1").parse({locale:"ch"}));
            alert('done');
        });

    </script>

</head>
<body>

<table>
    <tr>
        <td><label for="id1">Currency:</label></td>
        <td><input id="id1" name="id" type="text" fmt="$#,##0.00" value="100000asd"></td>
    </tr>
    <tr>
        <td><label for="id2">Percentage:</label></td>
        <td><input id="id2" name="id" type="text" fmt="#,##0.00 %" value="100.00"></td>
    </tr>
    <tr>
        <td><label for="id3">double:</label></td>
        <td><input id="id3" name="id" type="text" fmt="00-000.00" value="1"></td>
    </tr>
    <tr>
        <td><label for="id4">double:</label></td>
        <td><input id="id4" name="id" type="text" fmt="0.00" value="0.01"></td>
    </tr>
    <tr>
        <td><label for="id5">phone:</label></td>
        <td><input id="id5" name="id" type="text" fmt="(###) ###-####" value="5149993145"></td>
    </tr>
   <tr>
        <td><label for="id5">phone:</label></td>
        <td><input id="id6" name="id" type="text" fmt="(###) ###-####" value="5149993145"></td>
    </tr>
   <tr>
        <td><label for="id5">phone:</label></td>
        <td><input id="id7" name="id" type="text" fmt="(###) ###-####" value="5149993145"></td>
    </tr>
   <tr>
        <td><label for="id5">phone:</label></td>
        <td><input id="id8" name="id" label="Phone:" type="text" fmt="(###) ###-####" value="5149993145"></td>
    </tr>

</table>

</body>
</html>